import java.util.Scanner;

public class demo04 {
    //次数差
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str=sc.nextLine();
        int[] arr=new int[26];
        for (int i = 0; i < str.length(); i++) {
            arr[str.charAt(i)-'a']++;
        }
        int max=0;
        int min=1;
        for (int i = 0; i < 26; i++) {
            if(max<arr[i]&&arr[i]!=0){
                max=arr[i];
            }
            if(min>arr[i]&&arr[i]!=0){
                min=arr[i];
            }
        }
        System.out.println(max-min);
        sc.close();
    }
}
